package com.ethan.java8;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author ethan
 * create 2018-08-03 上午11:39
 * desc
 **/
public class Test8 {
    public static void main(String[] args){
        //Base64
        final String text = "Base64 finally in Java 8!";

        final String encoded = Base64
                .getEncoder()
                .encodeToString( text.getBytes( StandardCharsets.UTF_8 ) );
        System.out.println( encoded );

        final String decoded = new String(
                Base64.getDecoder().decode( encoded ),
                StandardCharsets.UTF_8 );
        System.out.println( decoded );
    }
}
